package com.apiit.webserviceclient.activities;

import com.apiit.webserviceclient.R;
import com.apiit.webserviceclient.R.layout;
import com.apiit.webserviceclient.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class LoanItems extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_loan_items);
		
		Intent intename = getIntent();
		String []value = intename.getStringArrayExtra("array");
		
		TableLayout table = (TableLayout) findViewById(R.id.tableLayouttest);
		
		for(int i=0;i<value.length-4;i++)
		{
		    TableRow row=new TableRow(this);
		    String title = value[i].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "");
		    String itemCode = value[i+1].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "");
		    String bDate = value[i+2].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "");
		    String rDate = value[i+3].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "");
		    
		    TextView titlevalue=new TextView(this);
		    titlevalue.setText(""+title +"\t");
		    titlevalue.setTextSize(14);
		   
		    TextView itemCodevalue=new TextView(this);
		    itemCodevalue.setText(""+itemCode+"\t");
		    itemCodevalue.setTextSize(14);
		    
		    TextView bDatevalue=new TextView(this);
		    bDatevalue.setText(""+bDate +"\t");
		    bDatevalue.setTextSize(14);
		   
		    TextView rDatevalue=new TextView(this);
		    rDatevalue.setText(""+rDate+"\n");
		    rDatevalue.setTextSize(14);
		    
		    row.addView(titlevalue);
		    row.addView(itemCodevalue);
		    row.addView(bDatevalue);
		    row.addView(rDatevalue);
		    table.addView(row);
		    i= i+4;
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.loan_items, menu);
		return true;
	}

}
